package com.cimu.activemq.topic;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;

import javax.jms.Topic;

/**
 * Title: TopicProducer
 * Copyright: Copyright (c) 2017
 *
 * date 2018年12月09日 18:12
 */
@Component
public class TopicProducer {
    @Autowired
    private JmsMessagingTemplate jmsTemplate;
    @Autowired
    private Topic demoTopic;

    public void send(String msg) {
        jmsTemplate.getJmsTemplate().setPubSubDomain(true);
        this.jmsTemplate.convertAndSend(this.demoTopic, msg);
    }

}
